<?php
define('ZWAPPID','wxbf04609a6665c8b7');
define('ZWAPPSECRET','b536825b78a166cc3b34a1609e5a76ba');
define('ZWMCHID','1505689671');
define('ZWAPIKEY','tccm1234tccm1234tccm1234tccm1234');
// define('LGHIDA','../../public/certificate/'.$zwstoreid.'/apiclient_cert.pem');
// define('LGHIDB','../../public/certificate/'.$zwstoreid.'/apiclient_key.pem');


ini_set('date.timezone','Asia/Shanghai');
//error_reporting(E_ERROR);
require_once "../lib/WxPay.Api.php";
require_once "WxPay.JsApiPay.php";
require_once 'log.php';

//①、获取用户openid
$tools = new JsApiPay();
//$openId = 'oPXH50C9np4ngdp1cTWaucPt0eLQ';
$openId =$_GET['openId'];
$money =$_GET['money']*100;
$goodtitle ='商品信息';
//②、统一下单
$time=date("YmdHis");
$input = new WxPayUnifiedOrder();
$input->SetBody($goodtitle);
$input->SetAttach($goodtitle);
$input->SetOut_trade_no(WxPayConfig::MCHID.$time);
$input->SetTotal_fee($money);
$input->SetTime_start(date("YmdHis"));
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetGoods_tag($goodtitle);
$input->SetNotify_url("http://paysdk.weixin.qq.com/example/notify.php");
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
$order = WxPayApi::unifiedOrder($input);
$order["lghtime"]=WxPayConfig::MCHID.$time;
$order["miyao"] = ZWAPIKEY;
//     json化返回给小程序端
    header("Content-Type: application/json");
    echo json_encode($order);
?>
